package com.yunji.storage.dao.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yunji.common.base.BaseDaoImpl;
import com.yunji.common.utils.bean.BeanUtils;
import com.yunji.storage.bo.RepairInfoListQueryBO;
import com.yunji.storage.dao.IRepairInfoDao;
import com.yunji.storage.domain.RepairInfoDO;
import com.yunji.storage.mapper.RepairInfoMapper;
import org.springframework.stereotype.Repository;

import java.util.Arrays;
import java.util.List;

@Repository
public class RepairInfoDaoImpl extends BaseDaoImpl<RepairInfoMapper, RepairInfoDO> implements IRepairInfoDao {
    @Override
    public List<RepairInfoDO> search(RepairInfoListQueryBO bo) {
        return list(new LambdaQueryWrapper<RepairInfoDO>()
                .eq(BeanUtils.isNotNull(bo.getRepairId()), RepairInfoDO::getRepairId, bo.getRepairId())
                .eq(BeanUtils.isNotNull(bo.getProductId()), RepairInfoDO::getProductId, bo.getProductId())
                .eq(BeanUtils.isNotNull(bo.getRepairCode()), RepairInfoDO::getRepairCode, bo.getRepairCode()));
    }

    @Override
    public boolean removeByRepairIds(Long... repairIds) {
        return remove(new LambdaQueryWrapper<RepairInfoDO>()
                .in(RepairInfoDO::getRepairId, Arrays.asList(repairIds)));
    }
}
